<template>
	<view class="page">
		<view class="header">
			<image class="header-icon" src="@/static/images/ranking/trophy.png"></image>
			<text class="header-title"> 排行榜</text>
			<text class="header-date">更新时间: {{date}}</text>
		</view>
		<view class="ranking">
			<view class="rangking-title">
				<text>排名</text>
				<text>昵称</text>
				<text>总收入</text>
			</view>
			<view class="ranking-list">
				<view class="ranking-list-item" v-for="(item, key) in rankingList" :key="key">
					<view class="ranking-list-number">
						<image v-if="key < 3" :src="'../../static/images/ranking/' + (key + 1) + '.png'"></image>
						<text v-else>{{key + 1}}</text>
					</view>
					<view class="ranking-list-nickname">
						<!-- <image src="../../static/images/ranking/trophy.png"></image> -->
						<text>{{ item.nickName}}</text>
					</view>
					<text class="ranking-list-score">{{zeroTwo(item.amount)}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		incomeRanking
	} from '@/api/my'

	export default {
		data() {
			return {
				list: [],
				rankingList: [],
				date: undefined
			}
		},
		onLoad() {
			incomeRanking().then(res => {
				console.log(res)
				this.rankingList = res.data
				this.date = res.data[0].time
			})
		}
	}
</script>

<style lang="scss">
	page {
		background: #E32248;
	}

	.page {
		padding-bottom: 20rpx;

		.header {
			display: flex;
			flex-direction: column;
			color: #fff;
			padding: 25rpx;
			position: relative;

			.header-icon {
				position: absolute;
				top: 25rpx;
				right: 25rpx;
				width: 160rpx;
				height: 160rpx;
			}

			.header-title {
				font-size: 40px;
				font-weight: bold;
				margin-bottom: 20rpx;
			}

			.header-date {
				font-size: 12px;
				color: #d6d6d6;
			}
		}

		.ranking {
			width: 700rpx;
			border-radius: 30rpx;
			margin: auto;
			background: #fff;
			box-sizing: border-box;
			padding: 20rpx;

			.rangking-title {
				display: flex;
				font-size: 14px;
				color: #555;
				height: 50rpx;
				line-height: 50rpx;

				text {
					display: block;
					width: 100rpx;
					text-align: center;

					&:nth-child(2) {
						box-sizing: border-box;
						padding-left: 20rpx;
						text-align: left;
						width: calc(100% - 200rpx);
					}
				}
			}

			.ranking-list-item {
				height: 110rpx;
				display: flex;
				align-items: center;
				font-size: 14px;
				border-bottom: 1px solid #f0f0f0;

				.ranking-list-number {
					width: 100rpx;
					color: #777;
					display: flex;
					justify-content: center;

					image {
						width: 50rpx;
						height: 50rpx;
					}
				}

				.ranking-list-score {
					display: block;
					width: 160rpx;
					color: #E28935;
					font-size: 16px;
					text-align: center;
				}

				.ranking-list-nickname {
					display: flex;
					align-items: center;
					width: calc(100% - 200rpx);
					box-sizing: border-box;
					padding-left: 20rpx;

					image {
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
						margin-right: 20rpx;
					}

					text {
						width: auto;
					}
				}
			}
		}
	}
</style>